<style>
  .picImg {
    width: 40px;
    height: 40px;
  }
</style>
<template>
  <div class="app-container">
    <div class="filter-container" style="display: flex">
      <el-form ref="editForm" :rules="editFormRules" :model="editForm" status-icon label-position="left"
               label-width="0px">
        <el-form-item prop="agentID">
          <el-select v-model="editForm.agentID" placeholder="请选择保代公司">
            <el-option
              v-for="item in options"
              :key="item.ID"
              :label="item.companyName"
              :value="item.ID">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div style="margin-left: 30px">
        <el-button type="primary" icon="el-icon-search" @click="getInput">查询</el-button>
      </div>
    </div>
    <!--&lt;!&ndash; 查询和其他操作 &ndash;&gt;-->
    <el-table v-loading="listLoading" :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row
              :header-cell-style="{background:'#92D3FF',color:'#fff'}">

      <el-table-column align="center" min-width="100" label="代理人姓名" prop="agentName"/>
      <el-table-column align="center" min-width="100" label="代理人身份证号" prop="agentID"/>
      <el-table-column align="center" min-width="100" label="代理人编码" prop="agentNo"/>
      <el-table-column align="center" min-width="100" label="保单总数" prop="billCount"/>
      <el-table-column align="center" min-width="100" label="保单总额 (元)" prop="billAmount"/>
      <el-table-column align="center" min-width="100" label="手续费总额 (元)" prop="fee"/>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="editForm.pageNum" :limit.sync="editForm.pageSize"
                @pagination="getList"/>
  </div>
</template>

<script>
  import {doGet, doPost} from '@/api'
  import {cities} from '@/utils/base'
  import Pagination from '@/components/Pagination' // Secondary package based on el-pagination

  export default {
    name: 'agentsearch',
    components: {Pagination},
    filters: {},
    data() {
      return {
        list: [],
        total: 0,
        listLoading: undefined,
        editForm: {
          agentID: undefined,
            pageNum: 1,
            pageSize: 20
        },
        editFormRules: {
          agentID: [{required: true, message: '请选择保代公司', trigger: 'blur'}]
        },
        options:[],
        editDialogVisible: false,
      }
    },
    created() {
      // this.getList()
      doGet('insuragent.html?op=list')
        .then(response => {
          this.options=response.rows
        })
        .catch(response => {
          this.options=[]
        })
    },
    methods: {
      getList() {
        this.listLoading = true
        doGet('agentsearch.html?op=list', this.editForm).then(response => {
          this.list = response.rows
            this.total = response.data.totalcount
          this.listLoading = false
        }).catch(() => {
          this.list = []
            this.total = 0
          this.listLoading = false
        })
      },

      getInput() {
        this.$refs['editForm'].validate(valid => {
          if (valid) {
            this.getList()
          }
        })
      }
    }
  }
</script>
